﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dln.Handler
{
    public class ResponseMessage
    {
        public String FromUserName { get; set; }
        public String ToUserName { get; set; }
        public String Content { get; set; }
        public String Kf { get; set; }
        public int ArticleCount { get; set; }
        public ResponseType ResponseType { get; set; }
        public String ResponseTest
        {
            get
            {
                string CreateTime = XMLNodeConfig.GetNowTime();
                switch (ResponseType)
                {
                    case ResponseType.Text:
                        return string.Format(TextTemplete, this.ToUserName, this.FromUserName, CreateTime, this.Content,"");
                    case ResponseType.News:
                        return string.Format(NewsTemplete, this.ToUserName, this.FromUserName, CreateTime, this.ArticleCount, this.Content);
                    case ResponseType.Customer:
                        return string.Format(CustomerTemplete, this.ToUserName, this.FromUserName, CreateTime);
                    case ResponseType.CustomerWithKf:
                        return string.Format(CustomerWithKfTemplete, this.ToUserName, this.FromUserName, CreateTime, Kf);
                    default:
                        return "";
                }
            }
        }
        public string TextTemplete = @"<xml>
                                           <ToUserName><![CDATA[{0}]]></ToUserName>
                                           <FromUserName><![CDATA[{1}]]></FromUserName>
                                           <CreateTime>{2}</CreateTime>
                                           <MsgType><![CDATA[text]]></MsgType>
                                           <Content><![CDATA[{3}]]></Content>
                                           <MsgId>{4}</MsgId>
                                       </xml>";
        public string CustomerTemplete = @"<xml>
                                           <ToUserName><![CDATA[{0}]]></ToUserName>
                                           <FromUserName><![CDATA[{1}]]></FromUserName>
                                           <CreateTime>{2}</CreateTime>
                                           <MsgType><![CDATA[transfer_customer_service]]></MsgType>
                                       </xml>";
        public string CustomerWithKfTemplete = @"<xml>
                                           <ToUserName><![CDATA[{0}]]></ToUserName>
                                           <FromUserName><![CDATA[{1}]]></FromUserName>
                                           <CreateTime>{2}</CreateTime>
                                           <MsgType><![CDATA[transfer_customer_service]]></MsgType>
                                            <TransInfo>
                                                <KfAccount>{3}</KfAccount>
                                            </TransInfo>
                                       </xml>";

        public string NewsTemplete = @"<xml>
                                           <ToUserName><![CDATA[{0}]]></ToUserName>
                                           <FromUserName><![CDATA[{1}]]></FromUserName>
                                           <CreateTime>{2}</CreateTime>
                                           <MsgType><![CDATA[news]]></MsgType>
                                           <ArticleCount>{3}</ArticleCount>
                                           <Articles>{4}</Articles>
                                       </xml>";

        public static string NewsChildTemplete = @"<item>
                                                <Title><![CDATA[{0}]]></Title>
                                                <Description><![CDATA[{1}]]></Description>
                                                <PicUrl><![CDATA[{2}]]></PicUrl>
                                                <Url><![CDATA[{3}]]></Url>
                                            </item>";

    }
    public enum ResponseType
    {
        Text,
        News,
        Voice,
        Customer,
        CustomerWithKf
    }
}
